# begin secrets
APP_SECRET  = 'shhitsasecret'
ADMIN_LOGIN = 'admin'
ADMIN_PASS  = 'pass'
# end secrets


SETTINGS_ENV_VAR = 'FLASKR_SETTINGS'
DB_FILE          = 'myapp.db'
DB_SCHEMA_FILE   = 'schema.sql'
INIT_DB_CMD      = 'initdb'

DB_ATTR      = 'sqlite_db'
DB_KEY       = 'DATABASE'
USERNAME_KEY = 'USERNAME'
PASSWORD_KEY = 'PASSWORD'
TESTING_KEY  = 'TESTING'

GET_METHOD      = 'GET'
POST_METHOD     = 'POST'
DELETE_METHOD   = 'DELETE'
SUCCESS_STATUS  = 200
REDIRECT_STATUS = 302
UNAUTH_STATUS   = 401
NOTFOUND_STATUS = 404

USERNAME_NAME = 'username'
PASSWORD_NAME = 'password'
DBID_NAME     = 'dbid'
TITLE_NAME    = 'title'
MESSAGE_NAME  = 'message'
DBID_KEY      = DBID_NAME
TITLE_KEY     = TITLE_NAME
MESSAGE_KEY   = MESSAGE_NAME
IS_AUTHED_KEY = 'logged_in'

ROOT_ROUTE         = '/'
LOGIN_ROUTE        = '/login'
LOGOUT_ROUTE       = '/logout'
INDEX_POSTS_ROUTE  = '/posts'
RESOURCE_PATH      = '/<resource>'
NEW_PATH           = '/new'
CREATE_PATH        = '/create'
EDIT_PATH          = '/edit'
UPDATE_PATH        = '/update'
DELETE_PATH        = '/delete'
SHOW_POST_ROUTE    = INDEX_POSTS_ROUTE + RESOURCE_PATH
NEW_POST_ROUTE     = INDEX_POSTS_ROUTE + NEW_PATH
CREATE_POST_ROUTE  = INDEX_POSTS_ROUTE + CREATE_PATH
EDIT_POST_ROUTE    = INDEX_POSTS_ROUTE + RESOURCE_PATH + EDIT_PATH
UPDATE_POST_ROUTE  = INDEX_POSTS_ROUTE + RESOURCE_PATH + UPDATE_PATH
DELETE_POST_ROUTE  = INDEX_POSTS_ROUTE + RESOURCE_PATH + DELETE_PATH
LOGIN_HTML         = 'login.html'
INDEX_POSTS_ACTION = 'index_posts'
SHOW_POST_ACTION   = 'show_post'
NEW_POST_ACTION    = 'new_post'
EDIT_POST_ACTION   = 'edit_post'
INDEX_POSTS_HTML   = INDEX_POSTS_ACTION + '.html'
SHOW_POST_HTML     = SHOW_POST_ACTION   + '.html'
NEW_POST_HTML      = NEW_POST_ACTION    + '.html'
EDIT_POST_HTML     = EDIT_POST_ACTION   + '.html'

FETCH_POSTS_SQL = 'SELECT id , title , message FROM posts ORDER BY id DESC'
FETCH_POST_SQL  = 'SELECT id , title , message FROM posts WHERE title IS (?)'
CREATE_POST_SQL = 'INSERT INTO posts (title , message) VALUES (? , ?)'
UPDATE_POST_SQL = 'UPDATE posts SET title = (?) , message = (?) WHERE id IS (?)'
DELETE_POST_SQL = 'DELETE FROM posts WHERE id IS (?)'
COUNT_POSTS_SQL = 'SELECT COUNT(*) FROM posts'

INIT_DB_MSG       = 'Initialized the database.'
LOGIN_TEXT        = b'You were logged in'
LOGOUT_TEXT       = b'You were logged out'
LOGIN_ERROR_TEXT  = b'Invalid username'
PASS_ERROR_TEXT   = b'Invalid password'
UNAUTHORIZED_TEXT = b'Unauthorized'
INDEX_POSTS_TEXT  = b'All Posts'
NO_POSTS_TEXT     = b'No posts here so far'
SHOW_POST_TEXT    = b"Showing post #"
NEW_POST_TEXT     = b'Create New Post'
CREATED_POST_TEXT = b'New post was successfully created'
EDIT_POST_TEXT    = b"Editing Post #"
UPDATED_POST_TEXT = b'Post was successfully updated'
DELETED_POST_TEXT = b'Post was successfully deleted'
